import request from '@/utils/request';
import { TableListParams } from './data.d';

export async function queryRule(params?: TableListParams) {
  return request('/api/rule', {
    params,
  });
}

export async function removeRule(params: { key: number[] }) {
  return request('/api/rule', {
    method: 'POST',
    data: {
      ...params,
      method: 'delete',
    },
  });
}

export async function addRule(params: TableListParams) {
  return request('/api/rule', {
    method: 'POST',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export async function updateRule(params: TableListParams) {
  return request('/api/rule', {
    method: 'POST',
    data: {
      ...params,
      method: 'update',
    },
  });
}

// 查询公告列表
export function listNotice(params: TableListParams) {
  return request('/system/notice/list', {
    method: 'GET',
    params,
  });
}

// 查询公告详细
export function getNotice(noticeId: number) {
  return request('/system/notice/' + noticeId, {
    method: 'get',
  });
}

// 新增公告
export function addNotice(data: TableListParams) {
  return request('/system/notice', {
    method: 'POST',
    data,
  });
}

// 修改公告
export function updateNotice(data: TableListParams) {
  return request('/system/notice', {
    method: 'PUT',
    data,
  });
}

// 删除公告
export function delNotice(noticeId: number | number[]) {
  return request('/system/notice/' + noticeId, {
    method: 'DELETE',
  });
}
